import areas from 'china-division/dist/areas.json';
import cities from 'china-division/dist/cities.json';
import provinces from 'china-division/dist/provinces.json';

//中国地址信息

areas.forEach((area) => {
  const matchCity: any = cities.filter((city) => city.code === area.cityCode)[0];
  if (matchCity) {
    matchCity.children = matchCity.children || [];
    matchCity.children.push({
      label: area.name,
      value: area.name,
    });
  }
});

cities.forEach((city) => {
  const matchProvince: any = provinces.filter((province) => province.code === city.provinceCode)[0];

  if (matchProvince) {
    matchProvince.children = matchProvince.children || [];
    matchProvince.children.push({
      label: city.name,
      value: city.name,
      // @ts-ignore
      children: city.children,
    });
  }
});

const options = provinces.map((province) => ({
  label: province.name,
  value: province.name,
  // @ts-ignore
  children: province.children,
}));
// console.log(options);
export default options;
